package router

import (
	"haiqiu-go-admin/controller"
	"haiqiu-go-admin/router/middleware"
	"net/http"
)

func Router() {

	http.HandleFunc("/captcha/", middleware.Chain(controller.API.CaptchaImg, middleware.Recover(), middleware.Method(http.MethodGet), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/captcha", middleware.Chain(controller.API.Captcha, middleware.Recover(), middleware.Method(http.MethodGet), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/login", middleware.Chain(controller.API.Login, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/system/theme", middleware.Chain(controller.API.SelectConfigByPrimaryKey, middleware.Recover(), middleware.Method(http.MethodGet), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/system/config", middleware.Chain(controller.ConfigAPI.SystemConfigHandle, middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/account/logout", middleware.Chain(controller.API.Logout, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))

	http.HandleFunc("/user/list", middleware.Chain(controller.UserAPI.UserPage, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/user/info", middleware.Chain(controller.UserAPI.UserInfo, middleware.Recover(), middleware.Method(http.MethodGet), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/user/all", middleware.Chain(controller.UserAPI.UserList, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/user", middleware.Chain(controller.UserAPI.UserHandle, middleware.Recover(), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/user/active", middleware.Chain(controller.UserAPI.Active, middleware.Recover(), middleware.Method(http.MethodPut), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/user/authRole", middleware.Chain(controller.UserAPI.AuthRole, middleware.Recover(), middleware.Method(http.MethodPut), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/user/resetPwd", middleware.Chain(controller.UserAPI.ResetPwd, middleware.Recover(), middleware.Method(http.MethodPut), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/user/avatar", middleware.Chain(controller.UserAPI.AvatarUpload, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))

	http.HandleFunc("/position", middleware.Chain(controller.PostAPI.PostHandle, middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/position/list", middleware.Chain(controller.PostAPI.PostPage, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/position/all", middleware.Chain(controller.PostAPI.PostList, middleware.Recover(), middleware.Method(http.MethodGet), middleware.Auth(), middleware.Logger()))

	http.HandleFunc("/role", middleware.Chain(controller.RoleAPI.RoleHandle, middleware.Recover(), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/role/active", middleware.Chain(controller.RoleAPI.Active, middleware.Recover(), middleware.Method(http.MethodPut), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/role/list", middleware.Chain(controller.RoleAPI.RolePage, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/role/all", middleware.Chain(controller.RoleAPI.RoleList, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/role/allocatedList", middleware.Chain(controller.RoleAPI.AllocatedList, middleware.Recover(), middleware.Method(http.MethodGet), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/role/unallocatedList", middleware.Chain(controller.RoleAPI.UnallocatedList, middleware.Recover(), middleware.Method(http.MethodGet), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/role/authorize", middleware.Chain(controller.RoleAPI.Authorize, middleware.Recover(), middleware.Method(http.MethodPut), middleware.Auth(), middleware.Logger()))

	http.HandleFunc("/auth/menu", middleware.Chain(controller.MenuAPI.Menu, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/auth/menu/list", middleware.Chain(controller.MenuAPI.MenuList, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/auth", middleware.Chain(controller.MenuAPI.MenuHandle, middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/auth/list", middleware.Chain(controller.MenuAPI.MenuPage, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/auth/all", middleware.Chain(controller.MenuAPI.MenuList, middleware.Recover(), middleware.Method(http.MethodGet), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/auth/tree", middleware.Chain(controller.MenuAPI.MenuTree, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/auth/roleMenuTreeSelect", middleware.Chain(controller.MenuAPI.RoleMenuTreeSelect, middleware.Recover(), middleware.Method(http.MethodGet), middleware.Auth(), middleware.Logger()))

	http.HandleFunc("/dept/tree", middleware.Chain(controller.DeptAPI.DeptTree, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/dept", middleware.Chain(controller.DeptAPI.DeptHandle, middleware.Recover(), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/dept/list", middleware.Chain(controller.DeptAPI.DeptPage, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/dept/all", middleware.Chain(controller.DeptAPI.DeptList, middleware.Recover(), middleware.Method(http.MethodGet), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/dept/active", middleware.Chain(controller.DeptAPI.Active, middleware.Recover(), middleware.Method(http.MethodPut), middleware.Auth(), middleware.Logger()))

	http.HandleFunc("/notice", middleware.Chain(controller.NoticeAPI.NoticeHandle, middleware.Recover(), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/notice/list", middleware.Chain(controller.NoticeAPI.NoticePage, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/notice/all", middleware.Chain(controller.NoticeAPI.NoticeList, middleware.Recover(), middleware.Method(http.MethodGet), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/notice/active", middleware.Chain(controller.NoticeAPI.Active, middleware.Recover(), middleware.Method(http.MethodPut), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/notice/statistics", middleware.Chain(controller.NoticeAPI.Statistics, middleware.Recover(), middleware.Method(http.MethodGet), middleware.Auth(), middleware.Logger()))

	http.HandleFunc("/system/log/statistics", middleware.Chain(controller.LogAPI.Statistics, middleware.Recover(), middleware.Method(http.MethodGet), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/system/log", middleware.Chain(controller.LogAPI.LogApiHandle, middleware.Recover(), middleware.Method(http.MethodGet), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/system/log/list", middleware.Chain(controller.LogAPI.LogPage, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))

	http.HandleFunc("/login/log/list", middleware.Chain(controller.LoginLogAPI.LoginLogPage, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Auth(), middleware.Logger()))
	http.HandleFunc("/login/log", middleware.Chain(controller.LoginLogAPI.LoginLogHandle, middleware.Recover(), middleware.Auth(), middleware.Logger()))

	http.HandleFunc("/file/theme/upload", middleware.Chain(controller.ConfigAPI.UploadTheme, middleware.Recover(), middleware.Method(http.MethodPost), middleware.Logger()))

	http.Handle(middleware.StaticFileServer())

}
